<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta http-equiv="pragma" content="no-cache" />
	<link rel="stylesheet" href="/css/style.css" type="text/css"/>
	<script type="text/javascript" src="/js/jquery.js"></script>
	<script type="text/javascript" src="/js/util.js"></script>
	<script type="text/javascript" src="/js/swfobject.js"></script>
</head>
<script type="text/javascript">

var arguments = window.dialogArguments;
var resType = arguments[0];
var resurl = arguments[1];
var param = arguments[2];
window.returnValue = resurl;
$(document).ready(function() {
	if(resType != undefined) {
		$("#modelType").val(resType);
	}
	if(resurl != undefined) {
		$("#desturl").html(resurl);
	}
	$("#param").val(param);
	$("#upload_target").hide();
	$("#upload_form").submit(function(e) {
		$("#upload_target").load(function(ex) {
			doc = document.getElementById("upload_target").contentDocument;
			process_response(eval("data=" + doc.body.innerHTML));
		});
	});
	if(resurl != undefined && resurl != "") {
		showSwf(resurl);
	}
});

function process_response(data) {
	if(data.code == 1 ) {
		var path = data.result;
		resurl = path;
		$("#desturl").html(resurl);
		showSwf(path);
	}else{
		errDialog(data.message);
	}
}
function showSwf(path) {
	var flashvars = {
	    file: path,
	    autostart: true
	};
	var params = {
	    allowfullscreen: true,
	    allowscriptaccess: 'always',
	    wmode: 'transparent'
	};
	var attributes = {};
	swfobject.embedSWF(path,'showarea', 600, 400, "9.0.0", false, flashvars, params, attributes);
}
function finish() {
	window.returnValue = resurl;
	window.close();
}
function beforeWindowClose() {
	if(window.returnCallback) {
		window.returnCallback(window.returnValue);
	}
	window.onbeforeunload = null;
	return true;
}
</script>

<body onunload="beforeWindowClose()">
<div class="addarea">
<form id="upload_form" name="upload_form" action="/func/upload/" encoding="multipart/form-data" enctype="multipart/form-data" method="post" target="upload_target">
<input type="hidden" id="modelType" name="modelType"/>
<input type="hidden" id="param" name="param"/>
<input type="file" id="uploader" name="uploader"/>
<input type="submit" value="上传">
<input type="button" onclick="finish()" value="完成"/>
<span id="desturl"></span>
</form>
</div>
<div class="showarea" id="showarea">

</div>
<iframe id="upload_target" name="upload_target">

</iframe>
</body>